#ifndef CABSTATUS_H
#define CABSTATUS_H

#include <QWidget>
#include <QTimer>

namespace Hydra_CabStatus {

enum ACTIVE_STATUS
{
    ACTIVE,
    STANDBY,
    FAILURE,
};

}

using namespace Hydra_CabStatus;



class CabStatus : public QWidget
{
    Q_OBJECT

public:
    CabStatus(QWidget *parent = 0);
    void setLocalStatus(ACTIVE_STATUS state);
    void setRemoteStatus(ACTIVE_STATUS state);
    void setInterval(quint16 interval);

public slots:
    void refresh();

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);
    void initParam();
    void drawBody(QPainter *pPainter);
    void drawCabs(QPainter *pPainter);
    void drawtriangle(QPainter *pPainter, ACTIVE_STATUS state, bool local = 1);




private:
    ACTIVE_STATUS mLocalAcviveStatus = STANDBY;                                                 // 本端激活状态
    ACTIVE_STATUS mRemoteAcviveStatus = STANDBY;                                                // 远端激活状态
    QColor mActiveColor = QColor(45, 144 ,51);                                                  // 激活颜色
    QColor mStandyColor = QColor(255, 255, 255);                                                // 待机颜色
    QColor mFailureColor = QColor(189, 0, 0);                                                   // 故障颜色
    QColor mBodyColor = QColor(212, 212, 212);                                                  // 车身颜色
    quint8 mBodyWidthProportion = 20;                                                           // 车身宽度占控件宽度的百分比
    quint8 mBodyLengthWidthProportion = 90;                                                     // 车身长度(不包含2个激活头)和宽度的百分比
    quint8 mTrainLengthWidthProportion = 200;                                                   // 列车长度(包含2个激活头)和宽度的百分比
    QPoint mCenter;                                                                             // 控件中心点
    QPoint mLocalTop;                                                                           // 本端车头三角顶点
    QPoint mLocalLeft;                                                                          // 本端车头三角左边底角顶点
    QPoint mLocalRight;                                                                         // 本端车头三角右边底角顶点
    QPoint mRemoteTop;                                                                          // 远端车头三角顶点
    QPoint mRemoteLeft;                                                                         // 远端车头三角左边底角顶点
    QPoint mRemoteRight;                                                                        // 远端车头三角右边底角顶点
    QTimer mTimer;                                                                              // 刷新定时器
};

#endif // CABSTATUS_H
